package com.xdq.flight.core;

import com.xdq.flight.common.airline.api.FlightClientService;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

public class FlightClientLoader {
    public static void main(String[] args) throws MalformedURLException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        URL[] urls=new URL[1];
        urls[0]=new URL("file:"+"D:\\workspce\\flight-core\\src\\main\\resources\\jar\\flight-airline-cz.jar");
        URLClassLoader urlClassLoader=new URLClassLoader(urls);
        Class<?> czFlightDomClientClass=urlClassLoader.loadClass("com.xdq.flight.airline.cz.domestic.FlightClientServiceImpl");
        FlightClientService czFlightDomClientService= (FlightClientService) czFlightDomClientClass.newInstance();
        String domFlight=czFlightDomClientService.getFlight();
        System.out.println(domFlight);

        Class<?> czFlightIntlClientClass=urlClassLoader.loadClass("com.xdq.flight.airline.cz.intl.FlightClientServiceImpl");
        FlightClientService czFlightIntlClientService= (FlightClientService) czFlightIntlClientClass.newInstance();
        String intlFlight=czFlightIntlClientService.getFlight();
        System.out.println(intlFlight);
    }
}
